<?php
//Code by Nguyen Quoc Cuong
class models_hang extends connect
{
	function _listhang()
	{
		$sql = 'SELECT MaHang, TenHang, SanXuat FROM hang';
		$this->query_db($sql);
		return $this->fetchAll();
	}
	
	function _addhang($TenHang,$SanXuat)
	{
		$sql = "INSERT INTO hang VALUE ('','$TenHang','$SanXuat')";
		$this->query_db($sql);
	}
	
	function _delHang($id){
		$sql = "DELETE 
				FROM hang 
				WHERE MaHang = $id";
		$this->query_db($sql);
	}
	
	function _getHang($id){
		$sql = "
			SELECT MaHang, TenHang, SanXuat
			FROM hang
			WHERE MaHang = $id ";
		$this->query_db($sql);
		return $this->fetchOne();
	}
	
	function _updateHang($TenHang,$SanXuat,$id){
		$sql = "
				UPDATE hang
				SET TenHang = '$TenHang', SanXuat = '$SanXuat'
				WHERE MaHang = '$id'";
		$this->query_db($sql);
	}
	
}
?>